package Demo39;

/**
 * 替换说有的问号
 * https://leetcode.cn/problems/replace-all-s-to-avoid-consecutive-repeating-characters/description/
 */

class Solution {
    public static String modifyString(String ss) {
        char[] s = ss.toCharArray();
        int len = s.length;
        for(int i = 0; i < len;i++) {
            if(s[i] == '?') {
                for(char ch = 'a'; ch <= 'c';ch++) {
                    if((i == 0 || s[i - 1] != ch) && (i == len - 1 || s[i+1] != ch)) {
                        s[i] = ch;
                        break;
                    }
                }
            }
        }
        return String.valueOf(s);
    }
}